<!DOCTYPE html>
<html><head>
    <meta charset="utf-8">
    <title>web813</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__STATIC__/admin/style/bootstrap.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/font-awesome.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__STATIC__/admin/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__STATIC__/admin/style/demo.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/typicons.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/animate.css" rel="stylesheet">
    <script src="__STATIC__/admin/style/jquery_002.js"></script>


    <script src="__STATIC__/admin/plus/uploadify/jquery.uploadify.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#uploadify").uploadify({
                //插件自带  不可忽略的参数
                'swf': "__STATIC__/admin/plus/uploadify/uploadify.swf",
                //前台请求后台的url 不可忽略的参数
                'uploader':"{:url('cate/upimg')}",
             'progressData':'speed',
                //给上传按钮设置文字
                'buttonText': '上传文件',
                'buttonClass':'btn btn-azure',

                'fileTypeDesc': 'Image Files',
                //设定发送数据的name
                'fileObjName':'img',
                'onUploadSuccess':function (file,data,response) {
                    $("input[name='img']").val(data);
                   var cateimgsrc="/uploads/cateimg/"+data;
                    var cateimg="<img height='100' src='"+cateimgsrc+"'>";
                    $("#cateimg").html(cateimg);
                }

            });
            $("#uploadify-button").prepend("<i class='fa fa-upload'></i>");
            $("#uploadify-button").removeAttr('style');


        });
    </script>


    <script src="__STATIC__/admin/ueditor/ueditor.config.js"></script>
    <script src="__STATIC__/admin/ueditor/ueditor.all.min.js"></script>
    <script src="__STATIC__/admin/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script src="__STATIC__/admin/plus/layer/layer.js"></script>
</head>
<body>
<!-- 头部 -->
{include file="common/head"}

<!-- /头部 -->

<div class="main-container container-fluid">
    <div class="page-container">
        {include file="common/left"}
        <div class="page-content">
            <!-- Page Breadcrumb -->
            <div class="page-breadcrumbs">
                <ul class="breadcrumb">
                    <li>
                        <a href="{:url('index/index')}">系统设置</a>
                    </li>
                    <li>
                        <a href="{:url('cate/lst')}">栏目列表</a>
                    </li>

                    <li class="active">添加栏目</li>
                </ul>
            </div>
            <!-- /Page Breadcrumb -->

            <!-- Page Body -->
            <div class="page-body">

                <div class="row">
                    <div class="col-lg-12 col-sm-12 col-xs-12">
                        <form class="form-horizontal" role="form" action="" method="post" enctype="multipart/form-data">
                            <input name="id" type="hidden" value="{$cates.id}">
                            <div class="widget-main ">
                                <div class="tabbable">
                                    <ul class="nav nav-tabs tabs-flat" id="myTab11">
                                        <li class="active">
                                            <a data-toggle="tab" href="#home11">
                                                基本信息
                                            </a>
                                        </li>

                                        <li class="">
                                            <a data-toggle="tab" href="#profile11">
                                                SEO信息
                                            </a>
                                        </li>
                                        <li class="">
                                            <a data-toggle="tab" href="#profile12">
                                               栏目内容
                                            </a>
                                        </li>
                                    </ul>
                                    <div class="tab-content tabs-flat">
                                        <div id="home11" class="tab-pane active">

                                            <div class="form-group">
                                                <label for="" class="col-sm-2 control-label no-padding-right">所属模型</label>
                                                <div class="col-sm-6">
                                                    <select name="model_id">
                                                        {volist name="modelRes" id="model"}
                                                        <option {if condition="$model['id'] eq $cates['model_id']"} selected="selected"{/if} value="{$model.id}" >{$model.model_name}</option>
                                                        {/volist}
                                                    </select>
                                                </div>
                                                <p class="help-block col-sm-4 red">* 必填</p>
                                            </div>

                                            <div class="form-group">
                                                <label for="" class="col-sm-2 control-label no-padding-right">上级栏目</label>
                                                <div class="col-sm-6">
                                                    <select name="pid">
                                                        <option value="0">顶级栏目</option>
                                                        {volist name="cateRes" id="cate"}
                                                        <option {if condition="$cates['pid'] eq $cate['id']"} selected="selected"{/if} value="{$cate.id}"><?php echo str_repeat('-',$cate['level']*4)?>{$cate.cate_name}</option>
                                                        {/volist}
                                                    </select>
                                                </div>
                                                <p class="help-block col-sm-4 red">* 必填</p>
                                            </div>


                                            <div class="form-group">
                                                <label for="" class="col-sm-2 control-label no-padding-right">栏目名称</label>
                                                <div class="col-sm-6">
                                                    <input class="form-control" placeholder="" name="cate_name" value="{$cates.cate_name}" required="" type="text">
                                                </div>
                                                <p class="help-block col-sm-4 red">* 必填</p>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label no-padding-right">隐藏栏目</label>
                                                <div class="col-sm-6">
                                                    <label >
                                                      <input value="0" name="status" {if condition="$cates['status'] neq 1"} checked="checked"{/if} class="checkbox-slider colored-blue" type="checkbox">
                                                       <span class="text"></span>
                                                    </label>
                                                </div>
                                                <p class="help-block col-sm-4 red">* 必填</p>
                                            </div>
                                            <div class="form-group">
                                                <label  class="col-sm-2 control-label no-padding-right">栏目图片</label>
                                                <div class="col-sm-6">
                                                    <label>
                                                   <span  id="uploadify"></span>
                                                    <span class="text"></span>
                                                    <input value="{$cates.img}" name="img" type="hidden">
                                                    </label>
                                                    <label>
                                                        <div id="cancel" class="uploadify-button btn btn-azure">
                                                            <span class="uploadify-button-text"><i class="fa fa-rotate-left">撤销上传</i></span></div>
                                                    </label>
                                                </div>
                                            </div>
                                            {if condition="$cates['img'] neq ''"}
                                           <div id="cateimg" style="padding-left: 180px;"><img src="/uploads/cateimg/{$cates.img}" height="100"></div>
                                            {/if}
                                            <div class="form-group">
                                                <label for="" class="col-sm-2 control-label no-padding-right">栏目属性</label>
                                                <div class="col-sm-6">

                                                    <div class="radio" style="float: left;padding-left: 10px">
                                                        <label>
                                                            <input name="cate_attr" value="1" {if condition="$cates['cate_attr'] eq 1"} checked="checked" {/if} type="radio">
                                                            <span class="text">列表页栏目(可发布文章)</span>
                                                        </label>
                                                    </div>
                                                    <div class="radio" style="float: left;padding-left: 10px">
                                                        <label>
                                                            <input name="cate_attr" value="2" {if condition="$cates['cate_attr'] eq 2"} checked="checked" {/if} class="inverted" type="radio">
                                                            <span class="text">封面频道栏目</span>
                                                        </label>
                                                    </div>
                                                    <div class="radio" style="float: left;padding-left: 10px">
                                                        <label>
                                                            <input name="cate_attr" value="3" {if condition="$cates['cate_attr'] eq 3"} checked="checked" {/if} class="inverted" type="radio">
                                                            <span class="text">外链栏目</span>
                                                        </label>
                                                    </div>

                                                </div>
                                                <p class="help-block col-sm-4 red">* 必填</p>
                                            </div>
                                            <div class="form-group">
                                                <label for="username" class="col-sm-2 control-label no-padding-right">列表页模板</label>
                                                <div class="col-sm-6">
                                                    <input class="form-control" placeholder="" value="{$cates.list_tmp}" name="list_tmp" required="" type="text">
                                                </div>

                                                <p class="help-block col-sm-4 red">* 必填</p>
                                            </div>
                                            <div class="form-group">
                                                <label  class="col-sm-2 control-label no-padding-right">频道页模板</label>
                                                <div class="col-sm-6">
                                                    <input class="form-control" placeholder="" value="{$cates.index_tmp}" name="index_tmp" required="" type="text">
                                                </div>
                                                <p class="help-block col-sm-4 red">* 必填</p>
                                            </div>
                                            <div class="form-group">
                                                <label  class="col-sm-2 control-label no-padding-right">内容页模板</label>
                                                <div class="col-sm-6">
                                                    <input class="form-control" placeholder="" value="{$cates.article_tmp}" name="article_tmp" required="" type="text">
                                                </div>
                                                <p class="help-block col-sm-4 red">* 必填</p>
                                            </div>
                                            <div class="form-group">
                                                <label  class="col-sm-2 control-label no-padding-right">外链地址</label>
                                                <div class="col-sm-6">
                                                    <input class="form-control" placeholder="" value="{$cates.link}" name="link" type="text">
                                                </div>
                                                <p class="help-block col-sm-4 red">* 请以‘http://’开头</p>
                                            </div>
                                        </div>

                                        <div id="profile11" class="tab-pane">
                                            <div class="form-group">
                                                <label  class="col-sm-2 control-label no-padding-right">栏目标题</label>
                                                <div class="col-sm-6">
                                                    <input class="form-control" placeholder=""  value="{$cates.title}" name="title" required="" type="text">
                                                </div>
                                                <p class="help-block col-sm-4 red">* 必填</p>
                                            </div>
                                            <div class="form-group">
                                                <label  class="col-sm-2 control-label no-padding-right">关键词</label>
                                                <div class="col-sm-6">
                                                    <input class="form-control" placeholder="" value="{$cates.keywords}" name="keywords" required="" type="text">
                                                </div>
                                                <p class="help-block col-sm-4 red">* 必填</p>
                                            </div>
                                            <div class="form-group">
                                                <label  class="col-sm-2 control-label no-padding-right">描述</label>
                                                <div class="col-sm-6">
                                                  <textarea class="form-control" name="desc"> {$cates.desc}</textarea>
                                                </div>
                                            </div>
                                        </div>
                                        <div id="profile12" class="tab-pane">
                                            <div class="form-group">
                                                <div class="col-sm-6">
                                                    <textarea id="content" name="content"  >{$cates.content}</textarea>
                                                </div>
                                            </div>

                                        </div>
                                        <div class="form-group">
                                            <div class="col-sm-offset-2 col-sm-10">
                                                <button type="submit" class="btn btn-default">保存信息</button>
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>

            </div>
            <!-- /Page Body -->
        </div>
        <!-- /Page Content -->
    </div>
</div>

<!--Basic Scripts-->
<script src="__STATIC__/admin/style/bootstrap.js"></script>
<script src="__STATIC__/admin/style/jquery.js"></script>
<!--Beyond Scripts-->
<script src="__STATIC__/admin/style/beyond.js"></script>
<script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    UE.getEditor('content',{ toolbars:[
        [
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
            'directionalityltr', 'directionalityrtl', 'indent', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
            'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
            'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode'
        ]
    ], initialFrameWidth:780,initialFrameHeight:300,});

    $("#cancel").click(function () {
        $cateid={$cates.id};
        //var cateimg=$("#cateimg").find("img");
        var imgurl= $("input[name='img']").val();
        if(!imgurl){
            layer.msg('请先上传图片',{icon:2})
            return false;
        }
        layer.confirm('确定要撤销图片吗?', {icon: 3, title:'提示'}, function(index) {
            $('#cateimg').hide();
            $("input[name='img']").val('');
            $.ajax({
                type: "post",
                dataType: "json",
                data: {imgurl: imgurl, cateid: cateid},
                url: "{:url('Cate/delImg')}",
                success: function (data) {
                    if (data == 1) {
                        layer.msg('撤销成功!', {icon: 1})
                    } else {
                        layer.msg('撤销失败!', {icon: 2})
                    }
                }
            });
            layer.close(index);
        });
    });
    function changeTmp() {
        var pcateId = $("select[name=pid]").find("option:selected").val();
        if (pcateId != 0) {
            $.ajax({
                type: "post",
                dataType: "json",
                data: {cateid: pcateId},
                url: "{:url('Cate/ajaxCateInfo')}",
                success: function (data) {
                    $("input[name=list_tmp]").val(data.list_tmp);
                    $("input[name=index_tmp]").val(data.index_tmp);
                    $("input[name=article_tmp]").val(data.article_tmp);
                    $("select[name=model_id]").val(data.model_id);
                }
            });
        }
    }

    $("select[name=pid]").change(function () {
        changeTmp();
    });
</script>

</body></html>